#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

long long d[100], len[100];

const long long MAX = 10, mod = 1000000000LL;

long long target = 1000000000000000000LL;

long long ans = 0, count0 = 0, count2 = 0;

int pre = 0;

void dfs(long long num, int iter) {
    long long sq = (long long)sqrt(num);
    if (iter < MAX) {
        for (int i = 0; i < sq; i++) {
            dfs(d[iter] + i, iter + 1);
        }
        dfs(num, iter + 1);
    }

    d[iter] += sq; 
    len[iter] += sq + 1LL;

    if (iter == MAX) {
        long long start = d[iter] - sq, end = d[iter] - 1;
        long long sq2 = (long long)sqrt(start);
        long long toAdd = 0, count1 = 0;
        while (sq2 * sq2 <= end) {
            long long start1 = sq2 * sq2;
            if (start1 < start) start1 = start;
            long long end1 = (sq2+1)*(sq2+1) - 1;
            if (end1 > end) end1 = end;
            count1 += sq2 * (end1 - start1 + 1);
            sq2 += 1;
        }

        count1 += sq;
        toAdd += count1 + sq + 1;

        if (len[iter + 1] + toAdd >= target) {
            cout << "last calc\n";

            while (start <= end) {
                //how many count
                sq2 = (long long) sqrt(start);
                long long sq22 = target - len[iter+1];
                if (sq2 > sq22) sq2 = sq22;
                count2 += sq2;
                len[iter+1] += sq2;

                if (len[iter+1] < target) {
                count0 += 1;
                len[iter + 1] += 1;
                }
                start++;

                if (len[iter+1] == target)
                    break;
            }

            
            if (len[iter+1] < target) {
                long long t = target - len[iter+1];
                if (t < sq) sq = t;
                count2 += sq; 
                len[iter + 1] += sq;
            }

            if (len[iter + 1] < target) {
                ans += num;
                len[iter + 1] += 1;
            }

            cout << ans << ' ' << count0 << ' ' << count2 << endl;
            cout << "length: " << len[iter + 1] << endl;
            exit(0);
        }

        //ans
        ans = (ans + num) % mod;
        count0 = d[iter]-1;
        len[iter+1] += toAdd;
        count2 += count1;
    }
}

int main()
{
    for (int i = 0; i <= MAX; i++) d[i] = 1;
    dfs(1, 0);
    cout << len[MAX] << endl;
    cout << len[MAX+1] << endl;
    return 0;
}
